package output;

import main.Constants;

public enum OutputTypeEnum {
   RETURN_TO_SOURCE_NOTICE("Return to source notice/pm") {
	  @Override
	  public String getOutputType(final int... source) {
		 if (source.length == 0)
			throw new IllegalArgumentException("Must specify the source of the message");
		 return source[0] == Constants.PM_SOURCE ? "PRIVMSG" : "NOTICE";
	  }
   },
   RETURN_TO_SOURCE_MESSAGE("Return to source msg/pm") {
	  @Override
	  public String getOutputType(final int... source) {
		 return "PRIVMSG";
	  }
   },
   SEND_IN_PM("Send in pm") {
	  @Override
	  public String getOutputType(final int... source) {
		 return "PRIVMSG";
	  }
   },
   SEND_TO_MAIN_CHAN("Send to main chan") {
	  @Override
	  public String getOutputType(final int... source) {
		 return "PRIVMSG";
	  }
   },
   SEND_TO_ADMIN_CHAN("Send to admin chan") {
	  @Override
	  public String getOutputType(final int... source) {
		 return "PRIVMSG";
	  }
   },
   NOTICE_USER("Notice user") {
	  @Override
	  public String getOutputType(final int... source) {
		 return "NOTICE";
	  }
   },
   NOTICE_MAIN_CHAN("Notice main chan") {
	  @Override
	  public String getOutputType(final int... source) {
		 return "NOTICE";
	  }
   },
   NOTICE_ADMIN_CHAN("Notice admin chan") {
	  @Override
	  public String getOutputType(final int... source) {
		 return "NOTICE";
	  }
   };

   public static OutputTypeEnum fromString(final String in) {
	  for (OutputTypeEnum ote : values()) {
		 if (in.equalsIgnoreCase(ote.toString()))
			return ote;
	  }
	  throw new IllegalArgumentException("No such type exists");
   }

   private String name;

   OutputTypeEnum(final String name) {
	  this.name = name;
   }

   public abstract String getOutputType(int... source);

   @Override
   public String toString() {
	  return name;
   }
}
